home *** CD-ROM | disk | FTP | other *** search
/ Hráč 2004 August / Hrac_72_2004-08_dvd.iso / dema / Rapid Gun / rg_setup.exe / common / diffusemap_lmap.fx < prev    next >
Text File  |  2004-05-10  |  6KB  |  224 lines

  1. // LF2 Engine
  2. // (C) 2002-3 7FX
  3. //---------------------------------------------------------------------------
  4. #include "common.fxh"
  5. //---------------------------------------------------------------------------
  6. // Common parameters
  7. // Desc
  8. string desc : Description = "Mapuje difuzni texturu a lighmap texturu na mesh.";
  9. // Requirements
  10. string req : Requirements = "Diffusemap, lightmap";
  11. // vertex format
  12. string vf : VertexFormat = "POSITION | DIFFUSEMAP | LIGHTMAP"; // 321 (for export) 
  13. //---------------------------------------------------------------------------
  14. // Used constants
  15. const matrix cMtxWVP : WorldViewProjection;
  16. const int cAlphaRef : AlphaRef = 0;
  17. // Diffuse color, default white
  18. const float4 cDiffuse : Diffuse = {1.f, 1.f, 1.f, 1.f};
  19. // CullMode - NONE=1, CW=2, CCW=3
  20. const int cCullMode : CullMode = 3; // default CCW
  21. // Matrices for fixed function technique
  22. const matrix cMtxW : World;
  23. // Sampler filters
  24. DECLARE_TEX_SAMPLER_VALUES;
  25. //---------------------------------------------------------------------------
  26. // Diffuse map texture 
  27. texture2D diffusemap : DiffuseMap;
  28. // Light map texture
  29. texture2D lightmap : LightMap;
  30. //---------------------------------------------------------------------------
  31. // Diffuse map sampler
  32. sampler diffusemap_sampler = sampler_state
  33. {
  34.     Texture = <diffusemap>;
  35.     SET_TEX_SAMPLER_VALUES;
  36. };
  37. // Light map sampler
  38. sampler lightmap_sampler = sampler_state
  39. {
  40.     Texture = <lightmap>;
  41.     //SET_TEX_SAMPLER_FILTERS;
  42.     MipFilter = NONE; 
  43.     MinFilter = <cMinFlt>; 
  44.     MagFilter = <cMagFlt>;
  45.     AddressU = CLAMP;
  46.     AddressV = CLAMP;
  47. };
  48. //---------------------------------------------------------------------------
  49. // programs
  50. struct VS_OUTPUT
  51. {
  52.     float4 Position : POSITION;
  53.     float2 DiffuseMapCoord : TEXCOORD0;
  54.     float2 LightMapCoord : TEXCOORD1;
  55. };
  56.  
  57. // vertex shader
  58. VS_OUTPUT VS(float4 Position : POSITION, float2 DiffuseMapCoord : TEXCOORD0, float2 LightMapCoord : TEXCOORD1)
  59. {
  60.     VS_OUTPUT Out = (VS_OUTPUT)0;
  61.     Out.Position = mul(Position, cMtxWVP);
  62.     Out.DiffuseMapCoord = DiffuseMapCoord;
  63.     Out.LightMapCoord = LightMapCoord;
  64.     return Out;
  65. }
  66.  
  67. // pixel shader
  68. float4 PS(VS_OUTPUT In) : COLOR
  69. {
  70.     return cDiffuse * tex2D(diffusemap_sampler, In.DiffuseMapCoord) * tex2D(lightmap_sampler, In.LightMapCoord);
  71. }
  72.  
  73. //---------------------------------------------------------------------------
  74. // Technique with vertex and pixel shader
  75. technique vs11_ps11
  76. <
  77.     // streams for technique
  78.     string stream1 = "POSITION | DIFFUSEMAP | LIGHTMAP";
  79. >
  80. {
  81.     pass p0
  82.     <
  83.         // stream mapping
  84.         string streammap = "stream1";
  85.     >
  86.     {
  87.         AlphaRef = <cAlphaRef>;
  88.         CullMode = <cCullMode>;
  89.     
  90.         VertexShader = compile vs_1_1 VS();
  91.         PixelShader  = compile ps_1_1 PS();
  92.     }
  93. }
  94. //---------------------------------------------------------------------------
  95. // Basic technique - vertex shader, no pixel shader
  96. technique vs11_ps0
  97. <
  98.     // streams for technique
  99.     string stream1 = "POSITION | DIFFUSEMAP | LIGHTMAP";
  100. >
  101. {
  102.     pass p0
  103.     <
  104.         // stream mapping
  105.         string streammap = "stream1";
  106.     >
  107.     {
  108.         AlphaRef = <cAlphaRef>;
  109.         CullMode = <cCullMode>;
  110.         TextureFactor = <cDiffuse>;
  111.  
  112.         VertexShader = compile vs_1_1 VS();
  113.         
  114.         // simple multitexture
  115.         Sampler[0] = <diffusemap_sampler>;
  116.         Sampler[1] = <lightmap_sampler>;
  117.         ColorOp[0] = Modulate;
  118.         ColorArg1[0] = TFactor;
  119.         ColorArg2[0] = Texture;
  120.         AlphaOp[0] = Modulate;
  121.         AlphaArg2[0] = TFactor;
  122.         AlphaArg2[0] = Texture;
  123.         ColorOp[1] = Modulate;
  124.         ColorArg1[1] = Current;
  125.         ColorArg2[1] = Texture;
  126.         AlphaOp[1] = Modulate;
  127.         AlphaArg1[1] = Current;
  128.         AlphaArg2[1] = Texture;
  129.     }
  130. }
  131. //---------------------------------------------------------------------------
  132. // Basic technique - fixed function
  133. technique vs0_ps0
  134. <
  135.     // streams for technique
  136.     string stream1 = "POSITION | DIFFUSEMAP | LIGHTMAP";
  137.     //string stream1 = "POSITION | LIGHTMAP";
  138. >
  139. {
  140.     pass p0
  141.     <
  142.         // stream mapping
  143.         string streammap = "stream1";
  144.     >
  145.     {
  146.         // matrices
  147.         WorldTransform[0] = <cMtxW>;
  148.     
  149.         AlphaRef = <cAlphaRef>;
  150.         CullMode = <cCullMode>;
  151.         TextureFactor = <cDiffuse>;
  152.     
  153.         // simple multitexture
  154.         Sampler[0] = <diffusemap_sampler>;
  155.         Sampler[1] = <lightmap_sampler>;
  156.         ColorOp[0] = Modulate;
  157.         ColorArg1[0] = TFactor;
  158.         ColorArg2[0] = Texture;
  159.         AlphaOp[0] = Modulate;
  160.         AlphaArg2[0] = TFactor;
  161.         AlphaArg2[0] = Texture;
  162.         ColorOp[1] = Modulate;
  163.         ColorArg1[1] = Current;
  164.         ColorArg2[1] = Texture;
  165.         AlphaOp[1] = Modulate;
  166.         AlphaArg1[1] = Current;
  167.         AlphaArg2[1] = Texture;
  168.     }
  169. }
  170. //---------------------------------------------------------------------------
  171. // Basic technique - fixed function multipass - noteboooooks
  172. technique vs0_ps0mp
  173. <
  174.     // streams for technique
  175.     string stream1 = "POSITION | DIFFUSEMAP | LIGHTMAP";
  176. >
  177. {
  178.     pass p0
  179.     <
  180.         // stream mapping
  181.         string streammap = "stream1";
  182.     >
  183.     {
  184.         // matrices
  185.         WorldTransform[0] = <cMtxW>;
  186.     
  187.         AlphaRef = <cAlphaRef>;
  188.         CullMode = <cCullMode>;
  189.         TextureFactor = <cDiffuse>;
  190.     
  191.         Sampler[0] = <diffusemap_sampler>;
  192.         ColorOp[0] = Modulate;
  193.         ColorArg1[0] = TFactor;
  194.         ColorArg2[0] = Texture;
  195.         AlphaOp[0] = Modulate;
  196.         AlphaArg1[0] = TFactor;
  197.         AlphaArg2[0] = Texture;
  198.     }
  199.     
  200.     pass p1
  201.     <
  202.         // stream mapping
  203.         string streammap = "stream1";
  204.     >
  205.     {
  206.         // matrices
  207.         WorldTransform[0] = <cMtxW>;
  208.     
  209.         AlphaBlendEnable = true;
  210.         SrcBlend = DESTCOLOR;
  211.         DestBlend = ZERO;
  212.     
  213.         ZWriteEnable = false;
  214.         //ZFunc = EQUAL;
  215.     
  216.         // lighmap coordinates are second!
  217.         TexCoordIndex[0] = 1;
  218.     
  219.         Sampler[0] = <lightmap_sampler>;
  220.     }    
  221. }
  222. //---------------------------------------------------------------------------
  223.  
  224.